<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.eagle.commons.vo.tbl_PosOperatorDic"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>发票补打</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<jsp:include page="../common/easyui.jsp"></jsp:include>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/util.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>
	<script type='text/javascript' src="<%=request.getContextPath()%>/dwr/interface/PrintDwr.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath() %>/dateCommon/WdatePicker.js"></script>
	 <script type="text/javascript">
	 <% tbl_PosOperatorDic posoper = (tbl_PosOperatorDic)session.getAttribute("posoper");
       	  Integer posID = posoper.getBL_PosID();
       %>
	 //查询改时间内的通行费
	 $(function(){
	 
	 $('#print').datagrid({
				iconCls:'icon-save',
				pagination:true,
				autoRowHeight: false,
				striped: true,
				collapsible:true,
				rownumbers:true,
				url:'cardConsumsAction!getBuda.action',
				singleSelect:true,
				fitColumns:true,
				onClickRow:function(rowIndex, rowData){
				$("#pvlp").val(rowData.qVLP);
				$("#pmon").val(rowData.qExitTime)
				},
				columns:[[
				    {field:'ck',title:'选择',checkbox:true,width:80},
					{field:'quserName',title:'姓名',width:180},
					{field:'qVLP',title:'车牌号',width:200,rowspan:2},
					{field:'qpayCardID2',title:'卡号',width:200,rowspan:2},
					{field:'qcostMoney',title:'通行费（元）',width:180,rowspan:2},
					{field:'qOperType',title:'票据类型',width:180,rowspan:2,
						 formatter: function(value,row,index){
				                      if (row.qOperType==0){
					                   	return '储值月结发票';
			                           } else if(row.qOperType==1)
			                           {
				                        return '记账月结发票';
			                           }
			                                            }
					},
					{field:'qExitTime',title:'打印月份',width:200,rowspan:2},
					{field:'id',title:'打印预览',width:200,rowspan:2,align:'center',
					formatter: function(value,rowData,rowIndex){
						return "<a href='javascript:void(see())' class='easyui-linkbutton' iconCls='icon-search' ><img src='<%=request.getContextPath()%>/js/themes/icons/search.png' border='0' title='打印预览'/></a>";
					   }
					},
					{field:'do',title:'打印',width:200,align:'center', rowspan:2,
						formatter: function(value,rowData,rowIndex){
						return "<a href='javascript:void(0)' class='easyui-linkbutton' iconCls='icon-search'   onclick='getInvID(<%=posoper.getOperatorID()%>,3);' ><img src='<%=request.getContextPath()%>/js/themes/icons/print.png' border='0' title='打印'/></a>";
					   }
					}
				]]
				
				});
				
	 });
	 function doSearch(){ 
		 $('#print').datagrid('load',{    
          VLP: encodeURI($('#VLP').val()),    
          mon: $('#mon').val(),
          cardID: $('#cardID').val()
            
        });    
 	 }  
 	
 	 //打印预览
 	 function see(){
 	  var VLP;//
        var mon;//
          var posid =<%=posID%>;//
 	 		 var VLP = $("#pvlp").val();//
       			 var mon = $("#pmon").val();// 
 		 var url = "<%=path%>/run?__report=reports/Sprint.rptdesign&__format=html&__navigationbar=false&__parameterpage=false&__showtitle=false&VLP="+VLP+"&mon="+mon+"&posid="+posid;
	        	$("#mainBirt").attr("src",url);
	        	 
 	 }
 	  function print(flag){
 	 var num=$("#num").val();
 	 var inv=$("#inv").val();
 	 num=inv+","+num;//批次-票号
 	  $('#dlg').dialog('close');
 	  var VLP = $("#pvlp").val();//
        var mon = $("#pmon").val();//  
         var posid = <%=posID%>;// 
         if (flag==0) {
          var url = "<%=path%>/output?__report=reports/Tprint.rptdesign&__format=html&VLP="+VLP+"&mon="+mon+"&posid="+posid;
          window.open(url);
          }if(flag==1){//打印成功
           if(num=='' ||inv==''|| VLP=='' ||mon=='' ){
           $.messager.alert('系统提示', '您没有进行打印','info');
           return false;
           }
          	$.messager.confirm('系统提示', '是否打印成功?', function(r) {
                 if (r) {
                  //dwr 方法 操作数据库 成功后更新结果
          			PrintDwr.getPrint(VLP,mon,<%=posID%>,num,3,function(data){
          			if(data == ""){
	        		 $('#print').datagrid('load');    
					}else {
					$.messager.alert('系统提示', data,'info');
					}	
					});
               }
            });
         
			}
 	 }
 	 
 	 //获取当前票据号
 	 function getInvID(operid,status){
 	 PrintDwr.getInvID(operid,status,function(data){
 	 			data=data.split("-");
				if(data[0] != "") {
				 $("#num").val(data[0]);
				 $("#inv").val(data[1]);
					$('#dlg').dialog('open');
				}else {
				$.messager.alert('系统提示', data[1],'info');	
				}
			});
 	 }
 	  //票号检查是否打印
 	 function check(){
 	 var num=$("#num").val();//票号
 	 var inv=$("#inv").val();//批次
 	 PrintDwr.checkInvID(inv,num,function(data){
		if(data != "") {
		$.messager.alert('系统提示', data,'info');
		$('#dlg').dialog('close');
				}
 	 	});
 	 }
	 </script>
	 
  </head>
  
  <body>
   <div id="searchDiv" class="easyui-panel"  title="发票补打——查询条件" style="background-color:#EBF2FF;" collapsible="true">
		<form id="searchForm" method="post" style="margin-top:10px" action="">
	           <table >
					<tr>
					<td width="3%" >
							<div style="font-family:微软雅黑;font-size:12px;">卡号：</div>
						</td>
						<td width="15%" align="left">
							<input  class="easyui-validatebox" data-options="required:true"  type="text"  id="cardID" name="cardID" maxlength='20' style="width:200px;border:1px solid #ccc" />
						</td>
						<td width="3%" >
							<div style="font-family:微软雅黑;font-size:12px;">车牌号：</div>
						</td>
						<td width="15%" align="left">
							<input  class="easyui-validatebox" data-options="required:true"  type="text"  id="VLP" name="VLP" maxlength='14' style="width:200px;border:1px solid #ccc" />
						</td>
						
						<td width="5%" align="right">
							<div style="font-family:微软雅黑;font-size:12px;">打印月份:</div>
						</td>
						<td width="15%" align="left">
							<input id="mon" name="mon" class="Wdate" value="" type="text" onFocus="WdatePicker({dateFmt:'yyyy-MM'})" />
						<span>格式为：<font color='red'>YYYY-MM</font></span>
						</td>
						
					</tr>
					</table>
					<div align="center">
					<table >
					<tr></tr>
					<tr></tr>
					<tr>
						<td colspan="2" width="20%" >
							<table align="center">
								<tr>
									<td width="10%" align="center"> <a href="javascript:void(0)"  class="easyui-linkbutton" iconCls="icon-search"  onclick="doSearch()">查询</a>
									<a href="javascript:void(0)"  class="easyui-linkbutton" iconCls="icon-redo" onclick="$('#searchForm')[0].reset();" >重置</a>
                                    <a href="javascript:void(0)"  class="easyui-linkbutton" iconCls="icon-ok" onclick="print(1);" >打印完成</a>
                                    </td>   
								</tr>
							</table>
						</td>						
					</tr>
				</table>     
				</div>
		 </form>
	</div>
	 <div id="rs" class="easyui-panel"  title="查询结果" style="background-color:#EBF2FF;" collapsible="true">
	 <table id="print" style="width:auto;overflow:auto"></table>    
	 </div>
	 <div id="birt" class="easyui-panel"  title="预览结果" style="background-color:#EBF2FF;height: 500"  collapsible="true">
	 <iframe id="mainBirt"  frameborder="0"  src="<%=path%>/run?__report=reports/Sprint.rptdesign&__format=html&__navigationbar=false&__parameterpage=false&__showtitle=false&VLP='+'-'+'&mon='+'2000-13'+'&posid='+0;" style="width:100%;height:100%;left top repeat"></iframe>
	 </div>
	  <div id="dlg" class="easyui-dialog" title="系统提示" style="width:250px;height:200px;padding:10px"
            data-options="
            	closable:true,
            	closed:true,
                iconCls: 'icon-save'
            ">
        当前票据号：<input id="num" class="easyui-validatebox" data-options="required:true,validType:'length[1,8]'"  style="width:200px;border:1px solid #ccc" value="" onkeyup="check()"/></br>
                                      注: 如票号和当前票号不一致请修改 
              <a href="javascript:void(0)"  class="easyui-linkbutton" iconCls="icon-ok" onclick="print(0)" >确定</a>
              <a href="javascript:void(0)"  class="easyui-linkbutton" iconCls="icon-cancel" onclick=" $('#dlg').dialog('close');" >取消</a>
    </div>
    <input id="inv" type="hidden"/>
      <input id="pvlp" type="hidden"/>
    <input id="pmon" type="hidden"/>
  </body>
</html>
